import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
// 定义 interfacePar 的结构

type Result = {
  code: number;
  data?: Record<string, any>[];
  msg: string;
};
type add = {
  code: number;
  error: string;
};
type status = {
  code: number;
  error: string;
  status: number;
};
export type getHomeResult = {
  code: any;
  message: string;
  data?: {
    product: any;
    deviceInfo: any;
    interfaces: any;
  };
};
// 查询  进来的时候  读取当前的设备信息
export const getHomeData = (data?: object) => {
  return http.request<getHomeResult>(
    "post",
    baseUrlApi("console/information"),
    {
      data
    }
  );
};
// 查询  进来的时候  读取边缘采集的数据
export const getAcquisitionData = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("edgeAcquisition/get"), {
    data
  });
};
// 添加子设备的 数据
export const addDeviceData = (data?: object) => {
  return http.request<status>("post", baseUrlApi("edgeAcquisition/update"), {
    data
  });
};
// 删除子设备的 数据
export const deleteDeviceData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("edgeAcquisition/delete"), {
    data
  });
};
// 修改子设备的 列表的 数据
export const updateDeviceDataList = (data?: object) => {
  return http.request<status>(
    "post",
    baseUrlApi("edgeAcquisition/updateDevice"),
    {
      data
    }
  );
};
// 修改子设备的 数据
export const updateDeviceData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("edgeAcquisition/update"), {
    data
  });
};
// 删除变量的 数据
export const deleteVariableData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("edgeAcquisition/deleteVar"), {
    data
  });
};

//   添加 变量
export const addVariableData = (data?: object) => {
  return http.request<status>("post", baseUrlApi("edgeAcquisition/addVar"), {
    data
  });
};
// 修改子设备 的 变量
export const updateVariableData = (data?: object) => {
  return http.request<status>("post", baseUrlApi("edgeAcquisition/updateVar"), {
    data
  });
};

// 复制 子设备的数据
export const copyDeviceData = (data?: object) => {
  return http.request<status>("post", baseUrlApi("edgeAcquisition/copyDev"), {
    data
  });
};
//  调试值下发
export const issuedValueData = (data?: object) => {
  // return http.request<status>("post", baseUrlApi("edgeAcquisition/copyDev"), {
  //   data
  // });
};
